<script type="text/javascript">
function jumpPage(pageNo) {
	$("#page_pageNo").val(pageNo);
		$("#mainForm").submit()
}

function go() {
   var goPage=$("#goPage").attr("value");
  
   var patrn=/^[0-9]*[1-9][0-9]*$/;  
   
   if (!patrn.exec(goPage)||goPage>${parameters.total}) {
		 $("#goPage").focus();
		 $("#pageError").html( "<span style='color:red;'>Please input valid page number!</span>");
	     return false;
    }else{
   		jumpPage(goPage);
	}
}

$(document).ready(function(){
	var totalPages = ${page.totalPages.toString()};
	
	if(totalPages<=1){
		$("img").removeAttr("onclick"); 
	}
});

function enterHandler(event){
	 var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	 if (keyCode == 13) {
	     return go();
	 } 
}

</script>

<input type="hidden" id="page_pageNo" name="page.pageNo" value="1">
<input type="hidden" id="totalPages" name="totalPages" value="${parameters.total}">

<div class="btnSet btnSetPaging">
	<div class="left">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td><img class="btn first" src="${parameters.ctx}/images/spacer.gif" onclick="javascript:jumpPage(1)" /></td>
				<td><img class="btn previous" src="${parameters.ctx}/images/spacer.gif" onclick="javascript:jumpPage(${parameters.pre})"/></td>
				<td><img class="btn next" src="${parameters.ctx}/images/spacer.gif" onclick="javascript:jumpPage(${parameters.next})"/></td>
				<td><img class="btn last" src="${parameters.ctx}/images/spacer.gif" onclick="javascript:jumpPage(${parameters.total})"/></td>
				
				<td><img src="${parameters.ctx}/images/spacer.gif" style="width: 10px; height: 1px"/></td>
				<td>Page ${parameters.no} of ${parameters.total}</td>
				<td><img src="${parameters.ctx}/images/spacer.gif" style="width: 10px; height: 1px"/></td>
				<td>Go to page</td>
				<td><img src="${parameters.ctx}/images/spacer.gif" style="width: 10px; height: 1px" /></td>
				
				<td><input class="inputText" type="text" id="goPage" name="goPage" style="width: 40px;" onkeydown=" return enterHandler(event); "/></td>
				
				<td><img src="${parameters.ctx}/images/spacer.gif" style="width: 5px; height: 1px" /></td>
				<td>
					<div class="button sbtn">
						<div class="left">
							<div class="right">
							<input class="inputButton" type="button" id="goPage" name="goPage" value="Go"
								   onclick="go()" style="font-size:13px;"/>
							</div>
						</div>
					</div>
				</td>
				<td>
					<div class="errorMessage" id="pageError"></div>
				</td>
			</tr>
		</table>
	</div>
</div>